package com.hsh.MySQLUtil.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hsh.MySQLUtil.mapper.StudentMapper;
import com.hsh.MySQLUtil.model.Student;
import com.hsh.MySQLUtil.util.QueryWrapperBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author hsh
 * @time 2023/7/24 4:01
 */
@RestController
public class StudentController {
    @Resource
    private StudentMapper studentMapper;

    @GetMapping("/test")
    public String test() {
        return "123";
    }

    @GetMapping("/find")
    public List find() {
//        QueryWrapper<Student> queryWrapper = new QueryWrapper<>();
//        queryWrapper.eq("age",18);
        Student student = new Student();
        student.setAge1(19);
        student.setName("张三");
        QueryWrapper<Student> queryWrapper = QueryWrapperBuilder.buildQueryWrapper(student);
        List<Student> students = studentMapper.selectList(queryWrapper);
        System.out.println(students);
        return students;
    }
}
